/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package trivia.gui;


import javax.microedition.lcdui.*;
import trivia.Subject;
import trivia.Subjects;

/**
 *
 * @author mourawi
 */
public class SubjectList extends List {

    private Subjects subjects;

    public SubjectList(Subjects subjects) {
      super("Subject", Choice.IMPLICIT);
      this.subjects = subjects;
      int max = subjects.getSubjectsNumber();
      for(int i=0; i<max; i++) {
          Subject set = subjects.getSubject(i);
          append(set.getName(), null);
      }
      addCommand(new Command("Exit", Command.EXIT, 0));
      addCommand(new Command("OK", Command.OK, 0));
    }

    public Subject getSelectedSubject() {
        return subjects.getSubject(this.getSelectedIndex());
    }
}
